Skip to content

feat: migrate BUI + root tests from Jest to Vitest (follow-up to FR-2609)#6875

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-21-feat_migrate_bui_root_tests_from_jest_to_vitest_follow-up_to_fr-2609_
Apr 30, 2026
Merged

feat: migrate BUI + root tests from Jest to Vitest (follow-up to FR-2609)#6875
graphite-app[bot] merged 1 commit intomainfrom
04-21-feat_migrate_bui_root_tests_from_jest_to_vitest_follow-up_to_fr-2609_

Conversation

@nowgnuesLee
Copy link
Copy Markdown
Contributor

@nowgnuesLee nowgnuesLee commented Apr 22, 2026

Follow-up to FR-2609. Extends the Vitest cutover to the two remaining Jest suites. No Jira ticket was created for this slice — scope is purely "finish the migration consistently across workspaces". If a Jira issue is needed for tracking, I'll link it after the fact.

Summary

packages/backend.ai-ui/ (14 files, 315 passing + 5 skipped)

  • New packages/backend.ai-ui/vitest.config.ts — mirrors react/vitest.config.ts plus vite-plugin-relay-lite (matches BUI's existing prod build pipeline).
  • New __test__/vitest.jest-compat.ts (same pattern) + __test__/jest-globals-shim.ts that redirects import { ... } from '@jest/globals' to a re-export from vitest.
  • Migrated jest.mock(...)vi.mock(...) in 4 files (only vi.mock is hoisted by Vitest).
  • BAIBackButton.test.tsx: converted jest.requireActual(...) to the async importOriginal factory pattern.
  • 4 rc-motion / jsdom-29 flaky tests skipped with // TODO(FR-2609) markers.

Root /src + /scripts (4 files, 90 passing + 1 skipped)

  • New /vitest.config.ts (Node env, minimal) + /__test__/vitest.jest-compat.ts.
  • Removed the Jest config block from root package.json; test script now runs vitest run.
  • scripts/i18n-merge-driver.test.ts: jest.mockvi.mock. The single fs-mock test is skipped with // TODO(FR-2609) — CJS require("fs") inside the plain .js driver doesn't pick up Vitest's mock.

Skip decisions (each with TODO(FR-2609) in source)

File Why skipped
4 tests in BUI (BAIButton, BAIUnmountAfterClose) rc-motion's supportTransition stays true under jsdom 29, waits for transitionend that never fires. Jest's older jsdom triggered the sync fallback.
1 test in i18n-merge-driver.test.ts vi.mock('fs', ...) doesn't propagate into the CJS require("fs") inside the JS driver.

Test plan

  • pnpm --prefix ./packages/backend.ai-ui run vitest → 315 pass, 5 skip
  • pnpm exec vitest run (root) → 90 pass, 1 skip
  • react/ (FR-2609) remains 856/856

Stack

Builds on FR-2609. Followed by FR-2611 which retires the CRA/Craco build system now that all test suites are off Jest.

Copy link
Copy Markdown
Contributor Author

nowgnuesLee commented Apr 22, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • flow:merge-queue - adds this PR to the back of the merge queue
  • flow:hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has required the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 22, 2026

Coverage report for ./react

Action wasn't able to generate report within GitHub comment limit. If you're facing this issue, please let me know by commenting under this issue.

Report generated by 🧪jest coverage report action from b598d84

@nowgnuesLee nowgnuesLee force-pushed the 04-21-feat_fr-2609_vitest_migration_for_react__96.9_pass_rate_822_848_tests_ branch from 21142d6 to f2d5ec5 Compare April 27, 2026 13:57
@nowgnuesLee nowgnuesLee force-pushed the 04-21-feat_migrate_bui_root_tests_from_jest_to_vitest_follow-up_to_fr-2609_ branch from ace1b59 to 818d02a Compare April 27, 2026 13:57
@nowgnuesLee nowgnuesLee marked this pull request as ready for review April 28, 2026 04:25
Copilot AI review requested due to automatic review settings April 28, 2026 04:25
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR completes the Jest → Vitest migration for the remaining test suites in the monorepo (repo-root /src + /scripts, and packages/backend.ai-ui/), aligning them with the existing react/ Vitest setup from FR-2609.

Changes:

  • Add new Vitest configs + Jest-compat shims for repo-root and packages/backend.ai-ui/.
  • Update tests to use Vitest-compatible mocking (vi.mock, async importOriginal) and refresh snapshots.
  • Remove leftover Jest config/deps, and skip known flaky tests with TODO(FR-2609) markers.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
vitest.config.ts Adds minimal Node-environment Vitest config for root /src and /scripts suites.
test/vitest.jest-compat.ts Adds root Jest→Vitest global shim (globalThis.jest = vi).
package.json Switches root test script from Jest to vitest run and removes embedded Jest config.
scripts/i18n-merge-driver.test.ts Updates mocking to vi.mock and skips a CJS-mock-incompatible test.
react/package.json Removes Jest-related devDependencies from the React workspace.
react/jest.config.cjs Deletes React Jest config file.
packages/backend.ai-ui/vitest.config.ts Adds BUI Vitest config mirroring React’s transform pipeline + Relay/SVGR support.
packages/backend.ai-ui/package.json Switches BUI tests from Jest to Vitest and updates devDependencies.
packages/backend.ai-ui/test/vitest.jest-compat.ts Adds BUI Jest→Vitest global shim (globalThis.jest = vi).
packages/backend.ai-ui/test/jest-globals-shim.ts Adds @jest/globals specifier shim to re-export from Vitest.
packages/backend.ai-ui/src/components/fragments/BAIDomainSelect.test.tsx Migrates jest.mockvi.mock.
packages/backend.ai-ui/src/components/BAIStatistic.test.tsx Migrates jest.mockvi.mock.
packages/backend.ai-ui/src/components/BAIBulkEditFormItem.test.tsx Migrates jest.mockvi.mock.
packages/backend.ai-ui/src/components/BAIBackButton.test.tsx Replaces jest.requireActual with Vitest async importOriginal pattern.
packages/backend.ai-ui/src/components/BAIFlex.test.tsx Updates mocks for Vitest compatibility.
packages/backend.ai-ui/src/components/snapshots/BAIFlex.test.tsx.snap Updates snapshot format/header to Vitest output.
packages/backend.ai-ui/src/components/BAIButton.test.tsx Skips flaky motion-related tests under jsdom 29 with TODO markers.
packages/backend.ai-ui/src/components/BAIUnmountAfterClose.test.tsx Skips flaky motion-related tests under jsdom 29 with TODO markers.
Comments suppressed due to low confidence (1)

scripts/i18n-merge-driver.test.ts:11

  • process.exit is being overwritten at module scope and never restored. That mutation can leak into other tests in the same Vitest worker and hide real failures (or break code that relies on the real exit behavior). Capture the original process.exit and restore it in afterEach/afterAll (and consider using vi.spyOn(process, 'exit') instead of direct assignment).
// Mock process.exit to avoid test termination
const mockExit = jest.fn();
process.exit = mockExit as any;

Comment thread scripts/i18n-merge-driver.test.ts
Comment thread packages/backend.ai-ui/package.json
Comment thread react/package.json
@nowgnuesLee nowgnuesLee force-pushed the 04-21-feat_migrate_bui_root_tests_from_jest_to_vitest_follow-up_to_fr-2609_ branch from 818d02a to 6c1b86d Compare April 28, 2026 05:02
@nowgnuesLee nowgnuesLee force-pushed the 04-21-feat_fr-2609_vitest_migration_for_react__96.9_pass_rate_822_848_tests_ branch from f2d5ec5 to 3b0c2a9 Compare April 28, 2026 05:02
@nowgnuesLee nowgnuesLee force-pushed the 04-21-feat_migrate_bui_root_tests_from_jest_to_vitest_follow-up_to_fr-2609_ branch from 6c1b86d to 7f03080 Compare April 28, 2026 05:15
@nowgnuesLee nowgnuesLee force-pushed the 04-21-feat_fr-2609_vitest_migration_for_react__96.9_pass_rate_822_848_tests_ branch 2 times, most recently from 411037f to c25e4c7 Compare April 28, 2026 05:19
@nowgnuesLee nowgnuesLee force-pushed the 04-21-feat_migrate_bui_root_tests_from_jest_to_vitest_follow-up_to_fr-2609_ branch from 7f03080 to 027a403 Compare April 28, 2026 05:19
@nowgnuesLee nowgnuesLee force-pushed the 04-21-feat_fr-2609_vitest_migration_for_react__96.9_pass_rate_822_848_tests_ branch from c25e4c7 to fd46dfb Compare April 28, 2026 05:25
@nowgnuesLee nowgnuesLee force-pushed the 04-21-feat_migrate_bui_root_tests_from_jest_to_vitest_follow-up_to_fr-2609_ branch 2 times, most recently from 1f59ad5 to d578ec5 Compare April 28, 2026 05:28
@nowgnuesLee nowgnuesLee force-pushed the 04-21-feat_fr-2609_vitest_migration_for_react__96.9_pass_rate_822_848_tests_ branch from fd46dfb to 593ff3b Compare April 28, 2026 05:28
@yomybaby yomybaby force-pushed the 04-21-feat_fr-2609_vitest_migration_for_react__96.9_pass_rate_822_848_tests_ branch from 593ff3b to 374a63e Compare April 30, 2026 12:08
@yomybaby yomybaby force-pushed the 04-21-feat_migrate_bui_root_tests_from_jest_to_vitest_follow-up_to_fr-2609_ branch from d578ec5 to 5fc6577 Compare April 30, 2026 12:08
@graphite-app
Copy link
Copy Markdown

graphite-app Bot commented Apr 30, 2026

Merge activity

) (#6875)

Follow-up to FR-2609. Extends the Vitest cutover to the two remaining Jest suites. No Jira ticket was created for this slice — scope is purely "finish the migration consistently across workspaces". If a Jira issue is needed for tracking, I'll link it after the fact.

## Summary

### `packages/backend.ai-ui/` (14 files, 315 passing + 5 skipped)
- New `packages/backend.ai-ui/vitest.config.ts` — mirrors `react/vitest.config.ts` plus `vite-plugin-relay-lite` (matches BUI's existing prod build pipeline).
- New `__test__/vitest.jest-compat.ts` (same pattern) + `__test__/jest-globals-shim.ts` that redirects `import { ... } from '@jest/globals'` to a re-export from `vitest`.
- Migrated `jest.mock(...)` → `vi.mock(...)` in 4 files (only `vi.mock` is hoisted by Vitest).
- `BAIBackButton.test.tsx`: converted `jest.requireActual(...)` to the async `importOriginal` factory pattern.
- 4 rc-motion / jsdom-29 flaky tests skipped with `// TODO(FR-2609)` markers.

### Root `/src` + `/scripts` (4 files, 90 passing + 1 skipped)
- New `/vitest.config.ts` (Node env, minimal) + `/__test__/vitest.jest-compat.ts`.
- Removed the Jest config block from root `package.json`; `test` script now runs `vitest run`.
- `scripts/i18n-merge-driver.test.ts`: `jest.mock` → `vi.mock`. The single `fs`-mock test is skipped with `// TODO(FR-2609)` — CJS `require("fs")` inside the plain `.js` driver doesn't pick up Vitest's mock.

### Skip decisions (each with `TODO(FR-2609)` in source)

| File | Why skipped |
|---|---|
| 4 tests in BUI (`BAIButton`, `BAIUnmountAfterClose`) | rc-motion's `supportTransition` stays `true` under jsdom 29, waits for `transitionend` that never fires. Jest's older jsdom triggered the sync fallback. |
| 1 test in `i18n-merge-driver.test.ts` | `vi.mock('fs', ...)` doesn't propagate into the CJS `require("fs")` inside the JS driver. |

## Test plan

- [x] `pnpm --prefix ./packages/backend.ai-ui run vitest` → 315 pass, 5 skip
- [x] `pnpm exec vitest run` (root) → 90 pass, 1 skip
- [x] `react/` (FR-2609) remains 856/856

## Stack

Builds on FR-2609. Followed by FR-2611 which retires the CRA/Craco build system now that all test suites are off Jest.
@graphite-app graphite-app Bot force-pushed the 04-21-feat_fr-2609_vitest_migration_for_react__96.9_pass_rate_822_848_tests_ branch from 374a63e to 40cf0a8 Compare April 30, 2026 12:15
@graphite-app graphite-app Bot force-pushed the 04-21-feat_migrate_bui_root_tests_from_jest_to_vitest_follow-up_to_fr-2609_ branch from 5fc6577 to b598d84 Compare April 30, 2026 12:16
Base automatically changed from 04-21-feat_fr-2609_vitest_migration_for_react__96.9_pass_rate_822_848_tests_ to main April 30, 2026 12:29
@graphite-app graphite-app Bot merged commit b598d84 into main Apr 30, 2026
5 of 7 checks passed
@graphite-app graphite-app Bot deleted the 04-21-feat_migrate_bui_root_tests_from_jest_to_vitest_follow-up_to_fr-2609_ branch April 30, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100~500 LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants